<%@page import="study.top.jsp.PageHandler"%>
<%@page import="study.top.mydb.items.WishListShowItem"%>
<%@page import="study.top.mydb.WishListProduct"%>
<%@page import="study.top.common.PatternChecker"%>
<%@page import="study.top.mydb.Member"%>
<%@page import="study.top.jsp.WebHandler"%>
<%@page import="study.top.mydb.Product"%>
<%@page import="study.top.mydb.items.ProductItem"%>
<%@page import="study.top.mydb.items.MemberItem"%>
<%@page import="study.top.mydb.WishList"%>
<%@page import="study.top.mydb.items.WishListItem"%>
<%@page import="java.util.ArrayList"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ page trimDirectiveWhitespaces="true"%>
<%@ page session="true"%>
<%@ include file="dbcon.jsp"%>

<!DOCTYPE html>
<html lang="ko">
<%@include file="topHead.jsp"%>

<body>
	<%@include file="topcategory.jsp"%>
	<div class="top-tab top-hidden-xs">
		<%@include file="tab.jsp"%>
	</div>
	<%
		db.connect();
		WishListProduct w = new WishListProduct();
		ArrayList<WishListShowItem> wishlist_list = w.wishListMember(mem_seq);
		if (mem_seq < 1) {
			out.print("<script type='text/javascript'>alert('로그인 해주세요.');window.location='uMemLogin.jsp';</script>");		
		}
			db.disconnect();
	%>
	<form name="form1">
		<div class="container">
			<div class="wish-header">
				<h2>
					<strong>WISH LIST</strong>
				</h2>
			</div>
			<div class="Info wishmargin">
				<p>회원님의 위시리스트입니다.</p>
				<br /> <br />
			</div>
		<div class="table-responsive">
			<div class="table-wishList" align="left">
				<div class="top-line2">
					<div class="top-tr1 ">
						<div class="top-td-forth top-hidden-xs">
							<strong>구분</strong>
						</div>
						<div class="top-td-fir">
							<strong>상품명</strong>
						</div>
						<div class="top-td-forth top-hidden-xs">
							<strong>우선순위</strong>
						</div>
						<div class="top-td-third">
							<strong>판매가</strong>
						</div>
						<div class="top-td-third">
							<strong>수량</strong>
						</div>
						<div class="top-td-third top-hidden-xs">
							<strong>적립금</strong>
						</div>
						<div class="top-td-fifth">
							<strong>합계</strong>
						</div>
						<div class="top-td-sixth ">
							<strong>선택</strong>
						</div>
					</div>

					<%
						int paysum=0;
						for (int i = 0; i < wishlist_list.size(); i++) {
						WishListShowItem item2 = wishlist_list.get(i);
						paysum+=item2.getSum();
					%>
					<div class="top-tr1 data-line" id="changerange">
						<div class="top-td-forth top-hidden-xs">
							<strong>기본배송</strong>
						</div>
						<div class="top-td-fir top-text-inline">
							<%=item2.getTitle()%>
						</div>
						<div class="top-td-forth top-hidden-xs"><%=item2.getRank()%></div>
						<div class="top-td-third">
							<span class="price"><%=item2.getPrice_min()%></span> 원
						</div>
						<div class="top-td-third">

							<input type="number" class="buynum"
								style="width: 50px; display: inline;"
								value="<%=item2.getQty()%>" name="buynum" min="1" /> <img
								src="img/qtychange.png" id="numchange"
								name="uWishListEditOk.jsp?seq=<%=item2.getSeq()%>&pseq=<%=item2.getProduct_seq()%>
						&wseq=<%=item2.getWishList_seq()%>&rank=<%=item2.getRank()%>">
						</div>
						<div class="top-td-third top-hidden-xs">
							<span class="point"><%=item2.getPoint()%></span>
							원&nbsp;&nbsp;&nbsp;
						</div>
						<div class="top-td-fifth">
							<span class="sum"><%=item2.getSum()%></span>
						</div>
						<div class="top-td-sixth">
							<input type="checkbox" name="chkbox" value="<%=item2.getSeq()%>" />
						</div>
					</div>
					<%
						}
					%>
				</div>
			</div>
		</div>
</div>
		<div class="table-wishList1">
			<div class="margin">
				<div class="td-sum">총 주문 합계 금액입니다.</div>
				<div class="td-sum top-hidden-xs"></div>
				<div class="td-sum top-hidden-xs"></div>
				<div class="td-sum" >
					상품 합계금액 : <span id="total_price"><%=paysum%></span>원
				</div>
			</div>
		</div>
		<div class="container">
			<div class="table-wishList1">

				<!-- <a href="uWishList.jsp" class="btn btn-sm btn-custom">선택삭제</a>  -->

				<input id="all_check" type="button" class="btn btn-sm btn-custom"
					value="전체선택" /> <input id="select_del" type="button"
					class="btn btn-sm btn-custom " value="선택삭제"
					src="uWishListDelete.jsp?no=<%=mem_seq%>" onclick="checkDel();">
				<input type="button" id="shopping" value="쇼핑계속하기 "
					class="btn btn-sm btn-custom btn-right"> <input
					type="button" id="order" value="상품주문 "
					src="uPayView.jsp?no=<%=mem_seq%>"
					class=" btn btn-sm
				btn-custom btn-right" onclick="check();">
				<br /> <br /> <br /> <br />
			</div>
		</div>
	</form>
	<div class="top-hidden-xs">
		<%@include file="topBottom.jsp"%>
	</div>
	<script src="assets/js/string.js"></script>
	<script type="text/javascript">
		$(function() {
			// 전체 삭제 버튼 클릭시
			$("#all_check").click(function() {
				// 전체 선택
				$("input[name='chkbox']").attr("checked", "checked");
			});

			// 선택 삭제 버튼 클릭시
			$("#select_del").click(function() {
				//사용자에게 물어본다.	 
				if (!confirm("정말삭제하시겠습니까?")) {
					//"취소"를 선택한 경우 처리 중단
					return false;
				}
				// 폼의 action속성을 다른 페이지로 지정 후, submit
				var url = $(this).attr("src");
				$("form[name='form1']").attr("action", url);
				$("form[name='form1']").attr("method", "post");
				$("form[name='form1']").submit();
			});
			// 쇼핑계속하기버튼 클릭시
			$("#shopping").click(function() {
				$("form[name='form1']").attr("action", "topmainpage.jsp");
				$("form[name='form1']").submit();
			});
			// 상품주문버튼 클릭시
			$("#order").click(function() {
				// 폼의 action속성을 다른 페이지로 지정 후, submit
				var url = $(this).attr("src");
				$("form[name='form1']").attr("action", url);
				$("form[name='form1']").attr("method", "post");
				$("form[name='form1']").submit();

			});

			//수량변경 이미지 클릭시
			$("img").click(function() {
				// 수량  span태그로 buynum라는 클래스이름을 지정한후, 사용
				var qty = $(this).parent().find(".buynum").val();
				if (qty) {
					qty = parseInt(qty);
				} else {
					qty = 0;
				}
				// 변경된 qty를 get방식으로 넘겨줌
				var url = $(this).attr("name");
				window.location = url + "&qty=" + qty;
			});
		});
	</script>
</body>
</html>

